<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>rest 参数</title>
</head>
<body>
    <script>
        // ES5 方式
        function join(){
            var str = "";
            for(var i = 0; i<arguments.length; i++){
                if(i == 0){
                    str = arguments[i];
                }else{
                    str += "|" + arguments[i];
                }
            }
            return str;
        }

        console.log(join("hello","world"));

        // ES6 方式
        function join2(...strs) {
            var str = "";
            for(var i=0; i<str.length; i++) {
                if(i == 0) {
                    str = strs[i];
                } else{
                    str += "|" + strs[i];
                }
            }
            return str;
        }
    </script>
</body>
</html>